var a = require("../../../mycomponent/yz_pay/yz_pay"), t = getApp();

Page({
    behaviors: [ a ],
    data: {
        language: "",
        order_id: "",
        goodList: [],
        totalNum: 0,
        totalPrice: "",
        order_sn: "",
        orderData: null,
        balance: 0,
        payParams: "",
        info_form: {},
        money: "",
        buttons: [],
        pay_sn: "订单编号",
        order_pay_id: "",
        mid: "",
        payerImg: "",
        payerName: "",
        pid: "",
        share_type: 1
    },
    confirm: function(a) {
        var t = a.currentTarget.dataset.value, e = a.currentTarget.dataset.btn;
        this.handlePay(e, t);
    },
    getPayerInfo: function() {
        var a = this, e = t.getNetAddresss("order.merge-pay.anotherPayOrder");
        e += "&order_ids=" + a.data.order_id + "&mid=" + a.data.mid, e += "&pid=" + a.data.pid, 
        t._getNetWork({
            url: e,
            success: function(t) {
                if (1 == t.data.result) {
                    var e = t.data.data;
                    a.setData({
                        payerImg: e.member.avatar,
                        payerName: e.member.nickname,
                        order_pay_id: e.order_pay.id,
                        buttons: e.buttons,
                        totalPrice: e.order_pay.amount
                    });
                } else wx.showToast({
                    title: t.data.msg,
                    icon: "none",
                    duration: 2e3,
                    success: function() {},
                    fail: function() {}
                }), console.log("错误", t.data.msg);
            },
            fail: function(a) {}
        });
    },
    getOrderDetail: function() {
        var a = this, e = t.getNetAddresss("order.another-pay-detail");
        e += "&order_id=" + a.data.order_id + "&mid=" + a.data.mid, e += "&pid=" + a.data.pid, 
        t._getNetWork({
            url: e,
            success: function(t) {
                console.log("ressss::::", t), 1 == t.data.result ? a.setData({
                    goodList: t.data.data
                }) : (wx.showToast({
                    title: t.data.msg,
                    icon: "none",
                    duration: 2e3
                }), console.log("错误", t.data.msg));
            },
            fail: function(a) {}
        });
    },
    onLoad: function(a) {
        if (console.log("options:", a), a.scene) {
            var t = decodeURIComponent(a.scene);
            if (t) {
                var e = [];
                e = t.split(",");
                for (var r = 0; r < e.length; r++) {
                    var o;
                    "t" == (o = e[r].split("="))[0] && this.setData({
                        share_type: o[1]
                    }), "id" == o[0] && this.setData({
                        order_id: o[1]
                    }), "p" == o[0] && this.setData({
                        pid: o[1]
                    });
                }
            }
        } else this.setData({
            order_id: a.id,
            pid: a.p
        }), 2 == a.share_type && this.setData({
            share_type: a.share_type
        });
        var s = wx.getStorageSync("yz_uid");
        this.setData({
            mid: s
        }), this.getPayerInfo(), this.getOrderDetail();
    },
    onReady: function() {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        });
    }
});